package com.newegg.nlp.util.corenlp.en;

import com.newegg.nlp.util.corenlp.Filter;
import com.newegg.nlp.util.corenlp.Keyword;
import com.newegg.nlp.util.corenlp.Result;
import com.newegg.nlp.util.corenlp.TagHelp;

import edu.stanford.nlp.ling.IndexedWord;
import edu.stanford.nlp.semgraph.SemanticGraph;
import edu.stanford.nlp.semgraph.SemanticGraphEdge;
import edu.stanford.nlp.simple.Sentence;

public class Filter_advcl implements Filter{

	@Override
	public Result filter(SemanticGraphEdge graphEdge, SemanticGraph graph, Sentence sentence) {
		Result result = new Result();
		if("advcl".equals(graphEdge.getRelation().getShortName())) { //依赖关系
			 IndexedWord source = graphEdge.getSource();
			 IndexedWord target = graphEdge.getTarget();
			 if(TagHelp.isJJ(source.tag()) && TagHelp.isNN(target.tag())) {
				 result.addKeyword(new Keyword(source.value() + " " + target.value(), source.value(), target.value()));
			 }
		 }
		return result;
	}

}
